// Filename: router.js
define([
    'jquery',
    'underscore',
    'backbone',
    ], function($, _, Backbone){
        var AppRouter = Backbone.Router.extend({
            routes: {
                'dashboard': 'dashboard',
                'dashboard/*path': 'dashboard',
                'article': 'article',
                'article/*path': 'article',
                'catalogue': 'catalogue',
                'catalogue/*path': 'catalogue',
                'section': 'section',
                'section/*path': 'section',
                'setting': 'setting',
                'setting/*path': 'setting',
                'slider': 'slider',
                'slider/*path': 'slider',
                'synce': 'synce',
                'synce/*path': 'synce',
                'tag': 'tag',
                'tag/*path': 'tag',
                'translate': 'translate',
                'translate/*path': 'translate',
                'language': 'language',
                'language/*path': 'language',
                'gallery': 'gallery',
                'gallery/*path': 'gallery',
                'faq': 'faq',
                'faq/*path': 'faq',
                'file_manager': 'fileManager',
                'file_manager/*path': 'fileManager',
                'video': 'video',
                'video/*path': 'video',
                'catalogue_media': 'catalogueMedia',
                'catalogue_media/*path': 'catalogueMedia',
                'ship': 'ship',
                'ship/*path': 'ship',
                'page': 'page',
                'page/*path': 'page',
                'seo': 'seo',
                'seo/*path': 'seo',
                '*actions': 'defaultAction'

            },
            dashboard: function(){
                require(['views/dashboard'], function (dashboardView) {
                    dashboardView.render();
                });
            },
            article: function(){
                require(['views/article'], function (articleView) {
                    articleView.render();
                });
            },
            article_static: function(){
                require(['views/article_static'], function (article_staticView) {
                    article_staticView.render();
                });
            },
            catalogue: function(){
                require(['views/catalogue'], function (catalogueView) {
                    catalogueView.render();
                });
            },
            section: function(){
                require(['views/section'], function (sectionView) {
                    sectionView.render();
                });
            },
            setting: function(){
                require(['views/setting'], function (settingView) {
                    settingView.render();
                });
            },
            slider: function(){
                require(['views/slider'], function (sliderView) {
                    sliderView.render();
                });
            },
            synce: function(){
                require(['views/synce'], function (synceView) {
                    synceView.render();
                });
            },
            tag: function(){
                require(['views/tag'], function (tagView) {
                    tagView.render();
                });
            },
            translate: function(){
                require(['views/translate'], function (translateView) {
                    translateView.render();
                });
            },
            language: function(){
                require(['views/language'], function (languageView) {
                    languageView.render();
                });
            },
            gallery: function(){
                require(['views/gallery'], function (galleryView) {
                    galleryView.render();
                });
            },
            faq: function(){
                require(['views/faq'], function(faqView){
                    faqView.render();
                });
            },
            fileManager: function(){
                require(['views/fileManager'], function(fileManagerView){
                    fileManagerView.render();
                });
            },
            video: function(){
                require(['views/video'], function(videoView){
                    videoView.render();
                });
            },
            catalogueMedia: function(){
                require(['views/catalogueMedia'], function(catalogueMediaView){
                    catalogueMediaView.render();
                });
            },
            ship: function(){
                require(['views/ship'], function(shipView){
                    shipView.render();
                });
            },
            page: function(){
                require(['views/page'], function(pageView){
                    pageView.render();
                });
            },
            seo: function(){
                require(['views/seo'], function(seoView){
                    seoView.render();
                });
            },
            defaultAction: function(actions){
            // We have no matching route, lets display the home page
            }
        });
        var initialize = function(){
            var app_router = new AppRouter;
            Backbone.history.start({
                pushState: true,
                //root: $base_url.replace("http://localhost", "") + "admincp/"
				root: "/admincp/"
            });
            var url = location.href;
            $('.language').click(function(event){
                require(['views/language'], function(languageView){
                    languageView.changeLanguage(event);
                });
            });
        };
        return {
            initialize: initialize
        };
    });